package com.hdaccp.service.impl;

import com.hdaccp.dao.FenLeiDao;
import com.hdaccp.dao.UserDao;
import com.hdaccp.entity.FenLei;
import com.hdaccp.entity.User;
import com.hdaccp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao ;
    @Autowired
    private FenLeiDao fenLeiDao ;


    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<User> getAllUser() {
        return userDao.query();
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void save() {
        User user = new User() ;
        user.setName("小小22222");
        userDao.save(user) ;
        int result = 10 / 0 ;
        FenLei fenLei = new FenLei() ;
        fenLei.setName("11111");
        fenLeiDao.save(fenLei) ;

    }
}
